import maya.cmds as cmds;
# cmds.SelectAll();
# cmds.Delete();

wallthickness_mount = 2.0; #taken from strykercode as a starting point

def createScrewMount(x,y):
    motorHoleRadius1 = 3.2/2.0; #actual = 3 adding fudge 
    motorHoleRadius2 = 6.2/2.0;#actual = 6 adding fudge   
    curve2 = cmds.curve(d=1,ep=[
    (0,0,0),
    (motorHoleRadius2,0,0),
    (motorHoleRadius1,wallthickness_mount,0),
    (0,wallthickness_mount,0),
    ]);
    curve2 = cmds.ls(sl=True)#work around
    cmds.nurbsToPolygonsPref( pc=300 )
    hole = cmds.revolve(curve2[0],ax=(0,1,0),p=(0,0,0),po=1,s=25,d=1);
    cmds.move(x,0,y);
    cmds.select(curve2[0]);
    cmds.Delete();
    return hole;

def createMotorMount():
    motorHolesRadius = 7.7/2.0;
    xSeparation = 19.0;
    ySeparation = 16.0;
    base = cmds.polyCylinder(r=motorHolesRadius,h=wallthickness_mount,sx=25);
    cmds.move(0,wallthickness_mount/2.0,0);
    hole1 = createScrewMount(0,ySeparation/2.0);
    hole2 = createScrewMount(0,-ySeparation/2.0);
    hole3 = createScrewMount(xSeparation/2.0,0);
    hole4 = createScrewMount(-xSeparation/2.0,0);
    
    for h in [hole1[0],hole2[0],hole3[0],hole4[0]]:
        cmds.select(base[0],h);
        base = cmds.polyBoolOp(op=1,useThresholds=1);
    return base;
    
